<%@ page language="java" contentType="text/html; charset=UTF-8"	 pageEncoding="UTF-8"%>
<%@ include file="../include/laypublic.jsp"%>
<!DOCTYPE html>
<html>
<head>
  <title>融资立项新增</title>
</head>
<style>
	.fieldset{
		margin-top: 5px;
		margin-bottom: 0px
	}
	.layui-legend{
		background-color:#5fb878;
		font-size:15px !important;
		width:140px;
	}
	.layui-form-item {
	    margin-bottom: 5px;
	    clear: both;
	    *zoom: 1;
	}
	.layui-form-label{width: 180px;}
	.width106{
		width:106px;
	}
	.width107{
		width:106px;
	}
	.width108{
		width:106px;
	}
	
	.finCostRow+.finCostRow{
	   border-top:1px solid #e0e0e0;
	   margin-top:20px;
	   padding-top:20px;
	}
	
</style>
<body>
<div class="layui-fluid">
    <div class="layui-card">
	    <div class="layui-tab-item layui-show">
	    	<div style="padding-top:15px;">&nbsp;</div>
			<form class="layui-form" id="addInfo_form" lay-filter="addInfo_form">
			<fieldset class="layui-elem-field layui-field-title fieldset"  id="baseInfo">
			<legend class="layui-btn layui-legend" style="text-align:left;cursor:default;">项目基础信息  ></legend>				
			  <div style="margin-top:20px">
			  	<div class="layui-form-item">
			  		<div class="layui-inline">
				      	<label class="layui-form-label">申请公司</label>
				      	<div class="layui-input-inline">
							<input type="hidden" name="hrOrgid" value="${bindOrgId}">
							<input type="text" value="${bindOrgName}" style="border:0px;width:220px" readonly="readonly" class="layui-input">
				      	</div>
				    </div>
				    <div class="layui-inline">
				    	<label class="layui-form-label">申请部门</label>
			      		<div class="layui-input-inline">
			      			<input type="hidden" name="hrDeptid" value="${bindDeptId}">
							<input type="text" value="${bindDeptName}" style="border:0px;" readonly="readonly" class="layui-input">
			      		</div>
				    </div>
				    <div class="layui-inline">
				    	<label class="layui-form-label">申请人</label>
			      		<div class="layui-input-inline">
			        		<input type="hidden" name="hrStaffApplyid" value="${SESSION_KEY_USER_DETAIL.hrStaffId }">
			        		<input type="text" name="staffname" value="${staffName }" readonly="readonly" style="border:0px" autocomplete="off" class="layui-input">
			      		</div>
				    </div>
			  	</div>
			  	<div class="layui-form-item">
			  		<div class="layui-inline">
					    <label class="layui-form-label">项目名称</label>
				      	<div class="layui-input-inline">
					      	<select id="add_select_proId" name="proname" lay-filter="add_select_proId" lay-verify="required" lay-search>
					      		<option value="">请选择-项目名称</option>
				      				<c:if test="${not empty allProName }">
				              			<c:forEach items="${allProName}" var="proNames">
				              				<option value="${proNames.proCode }">${proNames.proName }</option>
					            		</c:forEach>
				              		</c:if>
				      		</select>
				      	</div>
					</div>
					<div class="layui-inline">
		            	<label class="layui-form-label">立项日期</label>
		            	<div class="layui-input-inline">
		            		<input type="text" placeholder="立项日期" name="establishmentTime" id="sent-laydate-addTime" autocomplete="off" lay-verify="required" class="layui-input">
		            	</div>
          			</div>
				</div> 
			</div>
			</fieldset>
			<fieldset class="layui-elem-field layui-field-title fieldset"  id="finInformation">
	  			<legend class="layui-btn layui-legend" style="text-align:left;cursor:default;">融资信息 ></legend>
		  		<div style="margin-top:20px">
					<div class="layui-form-item">
						<div class="layui-inline">
		            	<label class="layui-form-label">金融机构</label>
			            	<div class="layui-input-inline">
			            		<input type="text" name="finOrg" placeholder="请输入金融机构名称" maxlength="100" autocomplete="off" lay-verify="required" class="layui-input">
			            	</div>
          				</div>
          				<div class="layui-inline">
					    <label class="layui-form-label">承贷企业</label>
					      	<div class="layui-input-inline">
						      	<select id="query-select-coopName" name="sgCoopId" lay-filter="query-select-coopName" lay-verify="required" lay-search>
						      		<option value="">请选择-承贷企业</option>
					      				<c:if test="${not empty coopInfoName }">
					              			<c:forEach items="${coopInfoName}" var="coops">
					              				<option value="${coops.id }">${coops.coopName }</option>
						            		</c:forEach>
					              		</c:if>
					      		</select>
					      	</div>
						</div>						
						<div class="layui-inline">
				    	<label class="layui-form-label">融资类型</label>
					    	<div class="layui-input-inline">
						    	<select name="capType" lay-verify="required">
					      			<option value="">请选择-融资类型</option>
					              	<option value="1">债权融资</option>
					              	<option value="2">股权融资</option>
					              	<option value="3">信托基金</option>
					              	<option value="9">其他</option>
								</select>
							</div>
				    	</div>
					</div>
					<div class="layui-form-item">
				    	<div class="layui-inline">
		            		<label class="layui-form-label">融资团队负责人</label>
			            	<div class="layui-input-inline">
			            		<input type="text" name="leader" placeholder="请输入融资团队负责人" maxlength="50" autocomplete="off" lay-verify="required|CHS" class="layui-input">
			            	</div>
          				</div> 		
				    	<div class="layui-inline">
							<label class="layui-form-label">融资小组成员</label>
							<div class="layui-input-inline">
								<textarea name="members" placeholder="请输入" class="layui-textarea" maxlength="500"
									lay-verify="required" style="width:499px;"></textarea>
							</div>
						</div>
					</div>
					<div class="layui-form-item">
						<div class="layui-inline">
					    	<label class="layui-form-label">总投资额（万元）</label>
				      		<div class="layui-input-inline">
					      		<input type="text" name="sumAmount" id="sumAmount" style="border:0px" readonly="readonly" class="layui-input">
				      		</div>
					    </div>
					    <div class="layui-inline">
					    	<label class="layui-form-label">我方股权比列（%）</label>
				      		<div class="layui-input-inline">
					      		<input type="text" name="stockPercent" id="stockPercent" style="border:0px" readonly="readonly" class="layui-input">
				      		</div>
					    </div>
						<div class="layui-inline">
					    	<label class="layui-form-label">我方股权出资金额（万元）</label>
				      		<div class="layui-input-inline">
					      		<input type="text" name="stockFund" id="stockFund" style="border:0px" readonly="readonly" class="layui-input">
				      		</div>
					    </div>
					</div>
					<div class="layui-form-item">
					    <div class="layui-inline">
					    	<label class="layui-form-label">融资金额（万元）</label>
				      		<div class="layui-input-inline">
					      		<input type="text" name="capAmount" placeholder="请输入融资金额" maxlength="11" autocomplete="off" onblur="isNumberAndFloat1(this);arabiaToCN(this,2);" lay-verify="required|floatAmount" class="layui-input">
				      		</div>
					    </div>
					    <div class="layui-inline">
					    	<label class="layui-form-label">合同融资成本（%）</label>
				      		<div class="layui-input-inline">
					      		<input type="text" name="capCost" placeholder="请输入合同融资成本" maxlength="11" autocomplete="off" onblur="isNumberAndFloat1(this);" lay-verify="required|floatAmount" class="layui-input">
				      		</div>
					    </div>
					</div>
					<div class="layui-form-item">
					    <div class="layui-inline">
					    	<label class="layui-form-label">担保方式</label>
				      		<div class="layui-input-inline">
					      		<input type="text" name="bailMode" placeholder="请输入担保方式" maxlength="50" autocomplete="off" lay-verify="required" class="layui-input">
				      		</div>
					    </div>
					    <div class="layui-inline">
					    	<label class="layui-form-label">预计到账日期</label>
				      		<div class="layui-input-inline">
					      		<input type="text" placeholder="预计到账时间" name="willArrivalDate" id="sent-laydate-willArrivalDate" autocomplete="off" lay-verify="required" class="layui-input">
				      		</div>
					    </div>
					</div>
					<div class="layui-form-item">
						<div class="layui-inline">
					    	<label class="layui-form-label">融资期限（含还本付息方式）</label>
				      		<div class="layui-input-inline">
				      		<textarea name="timeLimit" placeholder="请输入融资期限" class="layui-textarea" maxlength="500"
									lay-verify="required" style="width:899px;"></textarea>
				      		</div>
					    </div>
					</div>
					<div class="layui-form-item">
						<div class="layui-inline">
					    	<label class="layui-form-label">附加条件（含保证金或其他条件）</label>
				      		<div class="layui-input-inline">
					      		<textarea name="needMemo" placeholder="请输入附加条件" class="layui-textarea" maxlength="500"
									lay-verify="required" style="width:899px;"></textarea>
				      		</div>
					    </div>
					</div>
					<div class="layui-form-item">
						<div class="layui-inline">
					    	<label class="layui-form-label">综合成本说明</label>
				      		<div class="layui-input-inline">
					      		<textarea name="multiCost" placeholder="请输入综合成本说明" class="layui-textarea" maxlength="2000"
									lay-verify="required" style="width:899px;"></textarea>
				      		</div>
					    </div>
					</div>
				</div>
			</fieldset>   
			<fieldset class="layui-elem-field layui-field-title fieldset"  id="finCosts">
		  		<legend class="layui-btn layui-legend" style="text-align:left;cursor:default;">融资费用 ></legend>
				<div style="margin-top:20px">
				  	<div class="layui-form-item">
					    <div class="layui-inline">
					    	<label class="layui-form-label">序号</label>
				      		<div class="layui-input-inline">
					      		<input type="text" name="finCostShowInx" value="" readonly="readonly" style="border:0px" class="layui-input">
				      		</div>
					    </div>
					    <div class="layui-inline">
					      	<label class="layui-form-label" style="text-align:left;width:80px;">费用类型</label>
					      	<div class="layui-input-inline">
					        	<input type="text" name="costMemo" value="" readonly="readonly" style="border:0px" class="layui-input">
					      	</div>
					    </div>
					    <div class="layui-inline">
					      	<label class="layui-form-label" style="text-align:left;width:110px;">金额（万元）</label>
					      	<div class="layui-input-inline">
					        	<input type="text" name="costAmount" value="" readonly="readonly" style="border:0px" class="layui-input">
					      	</div>
					    </div>						    
				    </div>
				 <div style="margin-top:20px">  
				    <div class="layui-form-item" id="finCostRow1">
				    	<div class="layui-inline width106">
					    	<label class="layui-form-label">1</label>
					    	<div class="layui-input-inline">
					    		<input type="hidden" name="subFinCostShowIdx" value="1"/>
					    	</div>
					    </div>
					    <div class="layui-inline">
					    	<label class="layui-form-label"></label>
				      		<div class="layui-input-inline" style="margin-left:110px;">
					      		<input type="text" name="subCostMemo" placeholder="请输入费用类型" maxlength="500" autocomplete="off" lay-verify="required" class="layui-input">
				      		</div>
					    </div>
					    <div class="layui-inline">
					      	<label class="layui-form-label" style="width:80px;"></label>
					      	<div class="layui-input-inline">
					      		<input type="text" name="subCostAmount" placeholder="请输入金额" maxlength="11" autocomplete="off" onblur="isNumberAndFloat1(this);arabiaToCN(this,2);" lay-verify="required|floatAmount" class="layui-input">
					      	</div>
					    </div>
					    <div class="layui-inline">
					    	<button type="button" class="layui-btn layui-btn-sm" id="addFinCostBtn1" onclick="addFinCostRow(this);"><i class="layui-icon">&#xe654;</i></button>
					    	<button type="button" class="layui-btn layui-btn-sm" style="display:none" id="delFinCostBtn1" onclick="delFinCostRow(1)"><i class="layui-icon">&#xe640;</i></button>
					    </div>
				  </div>
				</div>
				<div style="margin-top:20px"> 
				  <div class="layui-form-item">
					<label class="layui-form-label">资金监管要求</label>
					<div class="layui-input-block">
						<textarea name="requires" class="layui-textarea" maxlength="500"
							lay-verify="required" placeholder="请根据金融机构要求填写" style="width:899px;height:90px;"></textarea>
					</div>
				 </div>
				</div>
				<div style="margin-top:20px">    
				  <div class="layui-form-item">
					<label class="layui-form-label">融资方案简介</label>
					<div class="layui-input-block">
						<textarea name="capSchemeMemo" placeholder="请输入" class="layui-textarea" maxlength="500"
							lay-verify="required" style="width:899px;height:90px;"></textarea>
					</div>
				 </div> 
				</div>
				<div style="margin-top:20px">   
				  <div class="layui-form-item">
					<label class="layui-form-label">融资计划</label>
					<div class="layui-input-block">
						<textarea name="capPlan" placeholder="请输入" class="layui-textarea" maxlength="500"
							lay-verify="required" style="width:899px;height:90px;"></textarea>
					</div>
				 </div> 
				</div>  
			 </div>		
			</fieldset>					  	
			<fieldset class="layui-elem-field layui-field-title fieldset"  id="workNodes">
		  		<legend class="layui-btn layui-legend" style="text-align:left;cursor:default;">工作节点 ></legend>
				<div style="margin-top:20px">
				  	<div class="layui-form-item">
					    <div class="layui-inline">
					    	<label class="layui-form-label">序号</label>
				      		<div class="layui-input-inline">
					      		<input type="text" name="workNodeShowInx" value="" readonly="readonly" style="border:0px" class="layui-input">
				      		</div>
					    </div>
					    <div class="layui-inline">
					      	<label class="layui-form-label" style="text-align:left;width:80px;">关键节点</label>
					      	<div class="layui-input-inline">
					        	<input type="text" name="keyPoint" value="" readonly="readonly" style="border:0px" class="layui-input">
					      	</div>
					    </div>
					    <div class="layui-inline">
					      	<label class="layui-form-label" style="text-align:left;width:110px;">进程</label>
					      	<div class="layui-input-inline">
					        	<input type="text" name="proMemo" value="" readonly="readonly" style="border:0px" class="layui-input">
					      	</div>
					    </div>						    
				    </div>
				    <div class="layui-form-item" id="workNodeRow1">
				    	<div class="layui-inline width107">
					    	<label class="layui-form-label">1</label>
					    	<div class="layui-input-inline">
					    		<input type="hidden" name="subWorkNodeShowIdx" value="1"/>
					    	</div>
					    </div>
					    <div class="layui-inline">
					    	<label class="layui-form-label"></label>
				      		<div class="layui-input-inline" style="margin-left:110px;">
					      		<input type="text" name="subKeyPoint" placeholder="请输入关键节点" maxlength="500" autocomplete="off" lay-verify="required" class="layui-input">
				      		</div>
					    </div>
					    <div class="layui-inline">
					      	<label class="layui-form-label" style="width:80px;"></label>
					      	<div class="layui-input-inline">
					      		<input type="text" name="subProMemo" placeholder="请输入进程" maxlength="500" autocomplete="off" lay-verify="required" class="layui-input">
					      	</div>
					    </div>
					    <div class="layui-inline">
					    	<button type="button" class="layui-btn layui-btn-sm" id="addWorkNodeBtn1" onclick="addWorkNodeRow(this);"><i class="layui-icon">&#xe654;</i></button>
					    	<button type="button" class="layui-btn layui-btn-sm" style="display:none" id="delWorkNodeBtn1" onclick="delWorkNodeRow(1)"><i class="layui-icon">&#xe640;</i></button>
					    </div>
				   </div>				  
				</div>		
			</fieldset>	
			<fieldset class="layui-elem-field layui-field-title fieldset"  id="workTargets">
		  		<legend class="layui-btn layui-legend" style="text-align:left;cursor:default;">工作目标 ></legend>
				<div style="margin-top:20px">
				  	<div class="layui-form-item">
					    <div class="layui-inline">
					    	<label class="layui-form-label" style="text-align:center;">序号</label>
				      		<div class="layui-input-inline" style="width:0px;">
					      		<input type="text" name="workTargetShowInx" value="" readonly="readonly" style="border:0px" class="layui-input">
				      		</div>
					    </div>
					    <div class="layui-inline">
					      	<label class="layui-form-label" style="text-align:left;width:90px;">工作目标</label>
					      	<div class="layui-input-inline" style="width:100px;">
					        	<input type="text" name="workAim" value="" readonly="readonly" style="border:0px" class="layui-input">
					      	</div>
					    </div>
					    <div class="layui-inline">
					      	<label class="layui-form-label" style="text-align:left;width:90px;">时间节点</label>
					      	<div class="layui-input-inline" style="width:100px;">
					        	<input type="text" name="timeNode" value="" readonly="readonly" style="border:0px" class="layui-input">
					      	</div>
					    </div>	
					    <div class="layui-inline">
					      	<label class="layui-form-label" style="text-align:left;width:80px;">完成任务</label>
					      	<div class="layui-input-inline" style="width:10px;">
					        	<input type="text" name="taskMemo" value="" readonly="readonly" style="border:0px" class="layui-input">
					      	</div>
					    </div>					    
				    </div>
				    <div class="layui-form-item" id="workTargetRow1">
				    	<div class="layui-inline width108">
					    	<label class="layui-form-label" style="text-align:center;">1</label>
					    	<div class="layui-input-inline">
					    		<input type="hidden" name="subWorkTargetShowIdx" value="1"/>
					    	</div>
					    </div>
					    <div class="layui-inline">
					    	<label class="layui-form-label" style="width:70px;"></label>
				      		<div class="layui-input-inline" style="margin-left:30px;">
					      		<input type="text" name="subWorkAim" placeholder="请输入工作目标" maxlength="500" autocomplete="off" lay-verify="required" class="layui-input">
				      		</div>
					    </div>
					    <div class="layui-inline">
					      	<label class="layui-form-label" style="width:0px;"></label>
					      	<div class="layui-input-inline">
					      		<input type="text" name="subTimeNode" placeholder="请输入时间节点" maxlength="500" autocomplete="off" lay-verify="required" class="layui-input">
					      	</div>
					    </div>
					    <div class="layui-inline">
					      	<label class="layui-form-label" style="width:0px;"></label>
					      	<div class="layui-input-inline">
					      		<input type="text" name="subTaskMemo" placeholder="请输入完成任务" maxlength="500" autocomplete="off" lay-verify="required" class="layui-input">
					      	</div>
					    </div>
					    <div class="layui-inline">
					    	<button type="button" class="layui-btn layui-btn-sm" id="addWorkTargetBtn1" onclick="addWorkTargetRow(this);"><i class="layui-icon">&#xe654;</i></button>
					    	<button type="button" class="layui-btn layui-btn-sm" style="display:none" id="delWorkTargetBtn1" onclick="delWorkTargetRow(1)"><i class="layui-icon">&#xe640;</i></button>
					    </div>
				   </div>				  
				</div>		
			</fieldset>
			<div style="margin-top:20px">	
				<div class="layui-form-item">
					<label class="layui-form-label">推进方式</label>
					<div class="layui-input-block">
						<textarea name="carryType" placeholder="请输入" class="layui-textarea" maxlength="500"
							lay-verify="required" style="width:899px;height:90px;"></textarea>
					</div>
				 </div>
				 <div style="margin-top:20px">   
				 <div class="layui-form-item">
					<label class="layui-form-label">与项目的沟通机制</label>
					<div class="layui-input-block">
						<textarea name="linkMode" placeholder="请输入" class="layui-textarea" maxlength="500"
							lay-verify="required" style="width:899px;height:90px;"></textarea>
					</div>
				 </div> 
				 </div>  
			</div>				
			<fieldset class="layui-elem-field layui-field-title" style="margin-top: 15px;">
                 <legend class="layui-btn layui-legend" style="text-align:left;cursor:default;">附件信息 ></legend>
                 <div style="margin-top:20px;">
	                 <div class="layui-form-item">
					    <label class="layui-form-label" style="width:350px;">支持pdf、excel、word、图片资料，可上传多个</label>
					</div>
	                 <div class="layui-form-item">
					    <label class="layui-form-label">附件资料（选填）</label>
					    <div class="layui-input-block">
					    	<div class="layui-upload">
				              	<button type="button" class="layui-btn" id="1-upload-more">上传</button>
		                		<div class="layui-upload-list" id="1-upload-more-list">
		                		</div>
				            </div>
					    </div>
				  	</div>
				  </div>
            </fieldset>	
                 		   
			<div class="layui-form-item" style="position: fixed ! important; right: 30px; bottom:45%;z-index:10000;">
				<div class="layui-input-block">
		      		<button class="layui-btn layui-bg-blue layui-btn-normal layui-btn-lg  layui-btn-radius" type="button" lay-submit lay-filter="addInfo_form_submit" id="addInfo_form_submit">
		      		<i class="layui-icon layui-icon-ok layuiadmin-button-btn"></i>
		      		提交
		      		</button>
		      	</div>
		    </div>
			</form>			
  		</div>
	</div>
</div>
  <script>
	//静态资源路径前缀
	var staticPath = '${fileHttpPre}';
	var stateJSON = <infopub:dicJson groupNo="A00010028" />;
	
  layui.config({
    base: '${ctx}/resources/layuiadmin/' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'set', 'upload', 'element', 'laydate'], function(){
    var $ = layui.$
    ,form = layui.form
    ,element = layui.element
    ,laydate = layui.laydate
    ,upload = layui.upload;
    
    laydate.render({
	      elem: '#sent-laydate-addTime'
	      ,format:'yyyy-MM-dd'
   	  	  ,value: new Date()
          ,done: function (value, date) {
         }
  	});
    laydate.render({
	      elem: '#sent-laydate-willArrivalDate'
	});
       
 	// 正则校验
	form.verify({
		//验证汉字
	    CHS:[
	    	/^[\u0391-\uFFE5]+$/
	    	,'只能输入汉字'
	  	],
	  	//名字校验
	  	COC: [
			/^[\u4e00-\u9fa5_a-zA-Z0-9]+$/
			,'请输入正确的名称'
	  	],
	  	//大于0的正整数
	  	intNumber:[
			/^[1-9]\d*$/
			,'请输入正确的数字'
	  	],
	  	//数字只能有两位小数
	  	floatNumber:[
			/^([-]?)([0-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/
			,'请输入正确的数字'
	  	],
	  	telNumber:[/^[1][3,4,5,7,8,9][0-9]{9}$/
			  		,'请输入正确的号码'
		],
	  	//数字大于等于0，并只能有两位小数
	  	floatAmount:[
			/^([0-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/
			//var pattern=/^((\d+\.\d*[1-9]\d{1})|(\d*[1-9]\d*\.\d{2}))$/; 
			,'请输入正确的数字'
	  	]
	});
	//项目名称select监听
    form.on('select(add_select_proId)', function(data){
    	var id = data.value;
    	if(id==""||id==null){
    		$('#sumAmount').val('');
    		$('#stockPercent').val('');
    		$('#stockFund').val('');
    		form.render();
    	}  	
    	getSetupFinByProId(id);   	
    }); 
	//多文件列表示例
    upload.render({
	      elem: '#1-upload-more'
	      ,url: basePath + '/setupFin/uploadAtt/'
	      ,data: {
	    	  types:1
	    		}
	      ,multiple: true
	      ,accept: 'file'
	      ,acceptMime: 'application/zip,application/x-rar-compressed,image/jpeg,image/png,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/pdf'
	   	  ,before: function(obj){ //obj参数包含的信息
	   		    layer.load(); //上传loading
	   		  }
	      ,done: function(res){
	    	  //如果上传失败
	          if(res.code > 0){
	        	  layer.closeAll('loading'); //关闭loading
	        	  return layer.msg(res.msg,{icon: 7});
	          }
	          //上传完毕
	   	  	  if(res.entity != null && res.entity.length > 0){
				for(var i in res.entity){
					var setupFin = res.entity[i];
					var arr = setupFin.split("|");
					var imgSrc = "";
					var suffix = arr[1].substring(arr[1].lastIndexOf(".")+1,arr[1].length);
					if(suffix == 'jpg' || suffix == 'png'){
						imgSrc = "${fileHttpPre}/"+arr[3];
					}else{
						imgSrc = "${ctx}/resources/images/"+suffix+".jpg";
					}
	        		$('#1-upload-more-list')
	        		.append('<div class="layui-upload-img-div" id="upload_img_'+arr[2]+'"><img src="'+imgSrc+'" title="'
	        				+ arr[1] +'" class="layui-upload-img"><div class="mask"><a href="javascript:void(0)" onclick="showImg(\''+"${fileHttpPre}"
	        						+arr[3] +'\');">查看</a><a href="javascript:void(0)" onclick="del(\''
	        								+arr[2]+'\')";>删除</a></div><p>'+arr[1]+'</p><input type="hidden" value="'
	        								+setupFin+'" id="fileAtt_'+arr[2]+'" name="fileAtt" ></input></div> ');
				}
		  	  }
	      }
	      ,allDone: function(obj){ //当文件全部被提交后，才触发
	    	  layer.closeAll('loading'); //关闭loading
	      }
	      ,error: function(){
	    	  layer.closeAll('loading'); //关闭loading
	          //上传失败
	          layer.msg("上传失败，请稍后再试~",{icon: 7});
	        }
	    });
   	//监听提交
  	form.on('submit(addInfo_form_submit)', function(data){
  		$("#addInfo_form_submit").removeAttr("lay-submit").removeClass("layui-bg-blue").addClass("layui-btn-disabled");
  		layer.load();
       	//提交 Ajax 成功后，静态更新表格中的数据
       	$.ajax({
           	type : 'post',
			url : basePath + '/setupFin/save',
           	data: $('#addInfo_form').serialize(),
			success:function(result){
				if(result.success){
					layer.closeAll('loading'); //关闭loading
					layer.msg('提交单据成功~',{icon: 1});
					//两秒后关闭当前页面
					setTimeout(function(){
						/**
						 * 查找父菜单，并刷新
						 */
						var topDoc = $(window.top.document);
						var path = basePath + '/setupFin/list';
						// 获取页面名称
						var name = topDoc.find(".layui-nav-item [lay-href^='" + path + "']").text();
						if(name == '' || name == null){
							name = '融资立项';
						}
						window.parent.layui.index.openTabsPage(path, name);
						var iframe = window.parent.layui.admin.tabsBody(window.parent.layui.admin.tabsPage.index).find(".layadmin-iframe");
						iframe[0].contentWindow.location.reload(true);
						
						/**
						 * 关闭当前页
						 */
						var currPath = basePath + '/setupFin/add';
						var layid = topDoc.find("li[lay-id^='" + currPath + "']").attr('lay-id');
						window.parent.layui.element.tabDelete('layadmin-layout-tabs', layid);//关闭当前页
				        }, 2000);
				}else{
					layer.closeAll('loading'); //关闭loading
  					$("#addInfo_form_submit").removeClass("layui-btn-disabled").addClass("layui-bg-blue").attr("lay-submit","");
					layer.msg(result.msg,{icon: 7});
			  	}
			}
       	});
   	});  
 	// data-type事件
    $('.layui-btn.layuiadmin-btn-admin').on('click', function(){
      var type = $(this).data('type');
      active[type] ? active[type].call(this) : '';
    });
  	
  });
		
	//新增融资费用一行
	function addFinCostRow(t){
		var $ = layui.$;
		var delBtnCount = $("button[id^='delFinCostBtn']").length;
		if(delBtnCount == 1){
			$("button[id^='delFinCostBtn']").each(function(){
				$(this).removeAttr("style");
			});
		}
		var thisid = $(t).attr("id").substring(13);
		thisid = $("div[id=finCostRow" + thisid + "]").find("div:first").find("label").html();
		thisid = parseInt(thisid);
		var nextIndex = parseInt(thisid) + 1;
		var maxInd = $("div[id^='finCostRow']").length;
		$("div[id^='finCostRow']").each(function(){
			var tId = $(this).attr("id").substring(10);
			tId = parseInt(tId);
		  	if(tId > maxInd){
		  		maxInd = parseInt(tId);
		  	}
		  	var thisIndex = $(this).find("div:first").find("label").html();
		  	thisIndex = parseInt(thisIndex);
		  	var nextId = thisIndex + 1;
		  	if(thisIndex > thisid) {
		  		$("div[id=finCostRow" + tId + "]").find("div:first").find("label").html(nextId);
		  	}
		});
		var ind = maxInd + 1;		
		var medalHtml = '';
		medalHtml += '<div class=layui-form-item id="finCostRow'+ind+'">';
		medalHtml += '	<div class="layui-inline width106">';
		medalHtml += '	<label class="layui-form-label">'+nextIndex+'</label>';
		medalHtml += '		<div class="layui-input-inline">';
		medalHtml += '			<input type="hidden" name="subFinCostShowIdx" value="'+nextIndex+'"/>';	
		medalHtml += '		</div>';	
		medalHtml += '	</div>';			
		medalHtml += '	<div class="layui-inline">';	
		medalHtml += '	<label class="layui-form-label"></label>';
		medalHtml += '		<div class="layui-input-inline" style="margin-left:110px;">';	
		medalHtml += '			<input type="text" name="subCostMemo" placeholder="请输入费用类型" maxlength="500" lay-verify="required" class="layui-input">';	
		medalHtml += '		</div>';	
		medalHtml += '	</div>';		
		medalHtml += '	<div class="layui-inline">';	
		medalHtml += '	<label class="layui-form-label" style="width:80px;"></label>';
		medalHtml += '		<div class="layui-input-inline">';	
		medalHtml += '			<input type="text" name="subCostAmount" onblur="isNumberAndFloat1(this);arabiaToCN(this,2);" placeholder="请输入金额" lay-verify="required|floatAmount" class="layui-input">';
		medalHtml += '		</div>';	
		medalHtml += '	</div>';	
		medalHtml += '	<div class="layui-inline">';
		medalHtml += '		<button type="button" class="layui-btn layui-btn-sm" id="addFinCostBtn'+ind+'" onclick="addFinCostRow(this);"><i class="layui-icon">&#xe654;</i></button>';
		medalHtml += '		<button type="button" class="layui-btn layui-btn-sm" id="delFinCostBtn'+ind+'" onclick="delFinCostRow('+ind+')"><i class="layui-icon">&#xe640;</i></button>';
		medalHtml += '		</div>';	
		medalHtml += '	</div>';
		$(t).parent().parent().after(medalHtml);
		layui.form.render();
	}
	
	//删除融资费用一行
	function delFinCostRow(id){
		var $ = layui.$;
		layui.layer.confirm('确定删除？',{icon:3, title :'提示'}, function(index){
			
			var thisid = $("div[id=finCostRow" + id + "]").find("div:first").find("label").html();
	    	thisid = parseInt(thisid);
	    	$("div[id^='finCostRow']").each(function(){
				var tId = $(this).attr("id").substring(10);
				tId = parseInt(tId);
			  	var thisIndex = $("div[id=finCostRow" + tId + "]").find("div:first").find("label").html();
			  	thisIndex = parseInt(thisIndex);
			  	var nextId = thisIndex - 1;
			  	if(thisIndex > thisid) {
			  		$("div[id=finCostRow" + tId + "]").find("div:first").find("label").html(nextId);
			  	}
			});
	    	$("#finCostRow"+id).remove();
	    	var delBtnCount = $("button[id^='delFinCostBtn']").length;
			if(delBtnCount == 1){
				$("button[id^='delFinCostBtn']").each(function(){
					$(this).attr("style","display:none");
				});
			}
			layui.layer.close(index);
			
 		});
	}
	
	//新增工作节点一行
	function addWorkNodeRow(t){
		var $ = layui.$;
		var delBtnCount = $("button[id^='delWorkNodeBtn']").length;
		if(delBtnCount == 1){
			$("button[id^='delWorkNodeBtn']").each(function(){
				$(this).removeAttr("style");
			});
		}
		var thisid = $(t).attr("id").substring(14);
		thisid = $("div[id=workNodeRow" + thisid + "]").find("div:first").find("label").html();
		thisid = parseInt(thisid);
		var nextIndex = parseInt(thisid) + 1;
		var maxInd = $("div[id^='workNodeRow']").length;
		$("div[id^='workNodeRow']").each(function(){
			var tId = $(this).attr("id").substring(11);
			tId = parseInt(tId);
		  	if(tId > maxInd){
		  		maxInd = parseInt(tId);
		  	}
		  	var thisIndex = $(this).find("div:first").find("label").html();
		  	thisIndex = parseInt(thisIndex);
		  	var nextId = thisIndex + 1;
		  	if(thisIndex > thisid) {
		  		$("div[id=workNodeRow" + tId + "]").find("div:first").find("label").html(nextId);
		  	}
		});
		var ind = maxInd + 1;		
		var medalHtml = '';
		medalHtml += '<div class=layui-form-item id="workNodeRow'+ind+'">';
		medalHtml += '	<div class="layui-inline width107">';
		medalHtml += '	<label class="layui-form-label">'+nextIndex+'</label>';
		medalHtml += '		<div class="layui-input-inline">';
		medalHtml += '			<input type="hidden" name="subWorkNodeShowIdx" value="'+nextIndex+'"/>';	
		medalHtml += '		</div>';	
		medalHtml += '	</div>';
		medalHtml += '	<div class="layui-inline">';	
		medalHtml += '	<label class="layui-form-label"></label>';
		medalHtml += '		<div class="layui-input-inline" style="margin-left:110px;">';	
		medalHtml += '			<input type="text" name="subKeyPoint" placeholder="请输入关键节点" maxlength="500" lay-verify="required" class="layui-input">';	
		medalHtml += '		</div>';	
		medalHtml += '	</div>';		
		medalHtml += '	<div class="layui-inline">';	
		medalHtml += '	<label class="layui-form-label" style="width:80px;"></label>';
		medalHtml += '		<div class="layui-input-inline">';	
		medalHtml += '			<input type="text" name="subProMemo" placeholder="请输入进程" maxlength="500" lay-verify="required" class="layui-input">';
		medalHtml += '		</div>';	
		medalHtml += '	</div>';		
		medalHtml += '	<div class="layui-inline">';
		medalHtml += '		<button type="button" class="layui-btn layui-btn-sm" id="addWorkNodeBtn'+ind+'" onclick="addWorkNodeRow(this);"><i class="layui-icon">&#xe654;</i></button>';
		medalHtml += '		<button type="button" class="layui-btn layui-btn-sm" id="delWorkNodeBtn'+ind+'" onclick="delWorkNodeRow('+ind+')"><i class="layui-icon">&#xe640;</i></button>';
		medalHtml += '		</div>';	
		medalHtml += '	</div>';

		$(t).parent().parent().after(medalHtml);
		layui.form.render();
	}
	
	//删除工作节点一行
	function delWorkNodeRow(id){
		var $ = layui.$;
		layui.layer.confirm('确定删除？',{icon:3, title :'提示'}, function(index){
			
			var thisid = $("div[id=workNodeRow" + id + "]").find("div:first").find("label").html();
	    	thisid = parseInt(thisid);
	    	$("div[id^='workNodeRow']").each(function(){
				var tId = $(this).attr("id").substring(11);
				tId = parseInt(tId);
			  	var thisIndex = $("div[id=workNodeRow" + tId + "]").find("div:first").find("label").html();
			  	thisIndex = parseInt(thisIndex);
			  	var nextId = thisIndex - 1;
			  	if(thisIndex > thisid) {
			  		$("div[id=workNodeRow" + tId + "]").find("div:first").find("label").html(nextId);
			  	}
			});
	    	$("#workNodeRow"+id).remove();
	    	var delBtnCount = $("button[id^='delWorkNodeBtn']").length;
			if(delBtnCount == 1){
				$("button[id^='delWorkNodeBtn']").each(function(){
					$(this).attr("style","display:none");
				});
			}
			layui.layer.close(index);
			
 		});
	}
	
	//新增工作目标一行
	function addWorkTargetRow(t){
		var $ = layui.$;
		var delBtnCount = $("button[id^='delWorkTargetBtn']").length;
		if(delBtnCount == 1){
			$("button[id^='delWorkTargetBtn']").each(function(){
				$(this).removeAttr("style");
			});
		}
		var thisid = $(t).attr("id").substring(16);
		thisid = $("div[id=workTargetRow" + thisid + "]").find("div:first").find("label").html();
		thisid = parseInt(thisid);
		var nextIndex = parseInt(thisid) + 1;
		var maxInd = $("div[id^='workTargetRow']").length;
		$("div[id^='workTargetRow']").each(function(){
			var tId = $(this).attr("id").substring(13);
			tId = parseInt(tId);
		  	if(tId > maxInd){
		  		maxInd = parseInt(tId);
		  	}
		  	var thisIndex = $(this).find("div:first").find("label").html();
		  	thisIndex = parseInt(thisIndex);
		  	var nextId = thisIndex + 1;
		  	if(thisIndex > thisid) {
		  		$("div[id=workTargetRow" + tId + "]").find("div:first").find("label").html(nextId);
		  	}
		});
		var ind = maxInd + 1;		
		var medalHtml = '';
		
		medalHtml += '<div class=layui-form-item id="workTargetRow'+ind+'">';
		medalHtml += '	<div class="layui-inline width108">';
		medalHtml += '	<label class="layui-form-label" style="text-align:center;">'+nextIndex+'</label>';
		medalHtml += '		<div class="layui-input-inline">';
		medalHtml += '			<input type="hidden" name="subWorkTargetShowIdx" value="'+nextIndex+'"/>';	
		medalHtml += '		</div>';	
		medalHtml += '	</div>';
		medalHtml += '	<div class="layui-inline">';	
		medalHtml += '	<label class="layui-form-label" style="width:70px;"></label>';
		medalHtml += '		<div class="layui-input-inline" style="margin-left:30px;">';	
		medalHtml += '			<input type="text" name="subWorkAim" placeholder="请输入工作目标" maxlength="500" lay-verify="required" class="layui-input">';	
		medalHtml += '		</div>';	
		medalHtml += '	</div>';
		medalHtml += '	<div class="layui-inline">';	
		medalHtml += '	<label class="layui-form-label" style="width:0px;"></label>';
		medalHtml += '		<div class="layui-input-inline">';	
		medalHtml += '			<input type="text" name="subTimeNode" placeholder="请输入时间节点" maxlength="500" lay-verify="required" class="layui-input">';
		medalHtml += '		</div>';	
		medalHtml += '	</div>';
		medalHtml += '	<div class="layui-inline">';	
		medalHtml += '	<label class="layui-form-label" style="width:0px;"></label>';
		medalHtml += '		<div class="layui-input-inline">';	
		medalHtml += '			<input type="text" name="subTaskMemo" placeholder="请输入完成任务" maxlength="500" lay-verify="required" class="layui-input">';
		medalHtml += '		</div>';	
		medalHtml += '	</div>';
		medalHtml += '	<div class="layui-inline">';
		medalHtml += '		<button type="button" class="layui-btn layui-btn-sm" id="addWorkTargetBtn'+ind+'" onclick="addWorkTargetRow(this);"><i class="layui-icon">&#xe654;</i></button>';
		medalHtml += '		<button type="button" class="layui-btn layui-btn-sm" id="delWorkTargetBtn'+ind+'" onclick="delWorkTargetRow('+ind+')"><i class="layui-icon">&#xe640;</i></button>';
		medalHtml += '		</div>';	
		medalHtml += '	</div>';	    
	   
		$(t).parent().parent().after(medalHtml);
		layui.form.render();
	}
	
	//删除工作目标一行
	function delWorkTargetRow(id){
		var $ = layui.$;
		layui.layer.confirm('确定删除？',{icon:3, title :'提示'}, function(index){
			
			var thisid = $("div[id=workTargetRow" + id + "]").find("div:first").find("label").html();
	    	thisid = parseInt(thisid);
	    	$("div[id^='workTargetRow']").each(function(){
				var tId = $(this).attr("id").substring(13);
				tId = parseInt(tId);
			  	var thisIndex = $("div[id=workTargetRow" + tId + "]").find("div:first").find("label").html();
			  	thisIndex = parseInt(thisIndex);
			  	var nextId = thisIndex - 1;
			  	if(thisIndex > thisid) {
			  		$("div[id=workTargetRow" + tId + "]").find("div:first").find("label").html(nextId);
			  	}
			});
	    	$("#workTargetRow"+id).remove();
	    	var delBtnCount = $("button[id^='delWorkTargetBtn']").length;
			if(delBtnCount == 1){
				$("button[id^='delWorkTargetBtn']").each(function(){
					$(this).attr("style","display:none");
				});
			}
			layui.layer.close(index);
			
 		});
	}
	
	//删除文件
	function del(index){
		layui.$("#fileAtt_"+index).remove();
		layui.$("#upload_img_"+index).remove();
	}
  
	//根据url查看文件
	function showImg(url){
		var openWin = window.open(url,'','left=410,height=768, width=1024, top=200,  toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');
	}
  	
	//根据项目编号带出所有需要的字段
	function getSetupFinByProId(proCode){
		var $ = layui.$
	  	,form = layui.form
			//获取所有该项目信息
			$.ajax({
				type : "POST", //提交方式  
				url : "${ctx}/setupFin/getSetupFinByProId",//路径  
				data : {
					"proCode" :proCode
				},//数据，这里使用的是Json格式进行传输  
				success : function(result) {//返回数据根据结果进行相应的处理 
					if(result.flag==true){
						form.val('addInfo_form',result.proList); // 填充原值
						var setupFin = result.proList;
						//总投资额
						var strSumAmountBuffer = "";										
						if(setupFin.proCode != null && setupFin.proName != null){								
							strSumAmountBuffer+= (parseFloat(setupFin.sumAmount)).toFixed(2);
						}
						$('#sumAmount').val(strSumAmountBuffer);
						//我方股权比列
						var strStockPercentBuffer = "";										
						if(setupFin.proCode != null && setupFin.proName != null){								
							strStockPercentBuffer+= setupFin.stockPercent;
						}
						$('#stockPercent').val(strStockPercentBuffer);
						//我方股权出资金额
						var strStockFundBuffer = "";										
						if(setupFin.proCode != null && setupFin.proName != null){								
							strStockFundBuffer+= (parseFloat(setupFin.stockFund)).toFixed(2);
						}
						$('#stockFund').val(strStockFundBuffer);
				        form.render();
					}else{
						layer.msg('数据通信异常~',{icon: 0});
					}
				} 
			});
		}
	//'请输入正确数字，且保留两位小数！'
	function isNumberAndFloat1(str) {
		var $ = layui.$, form = layui.form
		if (str.value == '' || str.value == null) {
			return;
		}
		var rgx = /^([-]?)([0-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/;

		var boolrgx = rgx.test(str.value);// true 
		if (boolrgx) {
			return true;
		} else {
			str.value =0;
			layer.msg('请输入正确的数字，且保留两位小数！');
			return false;
		}
	}
  </script>
</body>
</html>

